# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id$

PortSystem          1.0

# See dports/_resources/port1.0/group/kde4-1.1.tcl for more info.
PortGroup           kde4    1.1

name                rkward
version             0.6.5
# On next version or revision bump see notes in 'pre-activate' phase:
revision            1

conflicts           rkward-devel
categories          kde kde4 math science
maintainers         hhu.de:meik.michalke kde.org:rkward-devel mk
license             GPL-2+
platforms           darwin

description         KDE frontend to the R statistics language

long_description    RKWard aims to become an easy to use, transparent frontend to R, a powerful system \
                    for statistical computation and graphics. Besides a convenient GUI for the most important \
                    statistical functions, future versions will also provide seamless integration with an office-suite.

homepage            https://rkward.kde.org

master_sites        http://download.kde.org/stable/${name}/${version}/src

patchfiles          patch-dbus_session_startup.diff

worksrcdir          ${name}-${version}

depends_lib         port:kdelibs4 \
                    port:kate \
                    port:okular \
                    port:R

checksums           rmd160  9923d04eb522d5cf805bd3a628692a539eee820a \
                    sha256  a0fb7d084519e710ea3c7dc60bb92d24126bcb002bd1d1e00231f480e373f6c5

post-extract {
        file mkdir ${worksrcpath}/build
}

configure.dir       ${worksrcpath}/build
configure.args-append \
        -DNO_R_XML=1 \
        -DRKVERSION_NUMBER=${version} \
        -DBUNDLE_INSTALL_DIR=${applications_dir} \
        -DR_EXECUTABLE=${frameworks_dir}/R.framework/Resources/R

variant debug description {Add full debugging support} {
        depends_lib-append port:valgrind
}

configure.post_args ..

build.dir           ${worksrcpath}/build


# We force deletion of all residual (previously not properly destrooted) rkward files
# possibly installed on the buildbots, which otherwise fail for the rkward port
# [this should be deleted once the buildbots are clean again]:
pre-activate {
#   delete ${frameworks_dir}/R.framework/Resources/library/rkward/
#   delete ${frameworks_dir}/R.framework/Resources/library/rkwardtests/
#
#
# TODO: First we want to know the timestamps for further failure analysis,
#       which would have to be determined next time we have a revision bump.
#
    if {[file exists ${frameworks_dir}/R.framework/Resources/library/rkward]} {
        ui_msg "RKWARD_TIMESTAMPS:"
        system "ls -ltR ${frameworks_dir}/R.framework/Resources/library/rkward/"
    }
    if {[file exists ${frameworks_dir}/R.framework/Resources/library/rkwardtests]} {
        ui_msg "RKWARD_TIMESTAMPS:"
        system "ls -ltR ${frameworks_dir}/R.framework/Resources/library/rkwardtests/"
    }
#
# NOTE: rkward isn't binary distributable, which is why [1] doesn't exist!
#
# [1] http://packages.macports.org/rkward
}

livecheck.type      regex
livecheck.regex     ">Get RKWard (\\d+\\.\\d+\\.\\d+)<"

pre-pkg {
        file copy -force -- ${worksrcdir}/macports/postinstall ${package.scripts}/postinstall
        file attributes ${package.scripts}/postinstall -permissions 0755
}
